
#include "osgi-predefined.h"

#define HTTP_OK             200
#define HTTP_NOT_FOUND      404

#define SID_HttpClient  "SID_HttpClient"
#define IID_HttpClient  "IID_HttpClient"


#define SID_TestHttpClient  "SID_TestHttpClient"
#define IID_TestHttpClient  "IID_TestHttpClient"

#define  HTTP_DLL __attribute__((visibility("default")))

OSGI_NAMESPACE_BEGIN

enum HttpMethod
{
    post = 0,
    get,
};

OSGI_INTERFACE IInvokeResHandler
{
public:
        virtual void OSGI_API OnMsgRes(IMemBufReader* msgResContent,
                                        int invokeResCode
                                        ) = 0;
};


//HTTP应答类
OSGI_INTERFACE IHttpResponse : public IService
{
public:
    virtual int MKRAPI GetStatus(int *status) = 0;
    virtual int MKRAPI GetBody(void **ppBuf, int *len) = 0;
    virtual int MKRAPI Destroy() = 0;
};

//HTTP客户端类
OSGI_INTERFACE IHttpClient : public IService
{
public:
    virtual int MKRAPI SynMethod(const char *url,
                                HttpMethod method,
                                IHttpResponse **response,
                                const char* serviceName,
                                int timeout = -1,
                                 const char *parameters = 0) = 0;

    virtual int MKRAPI AsynMethod(const char *url,
                                HttpMethod method,
                                IHttpResponse **response,
                                IInvokeResHandler* resHandler,
                                const char* serviceName,
                                int timeout = -1,
                                const char *parameters = 0) = 0;

    virtual void MKRAPI Destroy() = 0;
};

OSGI_NAMESPACE_END

